package edu.hrbu.systemadmin.util;

import lombok.Builder;
import lombok.Getter;

/**
 * @author 徐登宇
 */
@Getter
@Builder
public class R {

    public static final int SUCCESS_CODE=0;
    public static final int ERROR_CODE=1;
    public static final String SUCCESS_MESSAGE="SUCCESS";
    public static final String ERROR_MESSAGE="ERROR";

    private int code;

    private String message;

    private Object data;

    public static R ok(){
        return R.builder().code(SUCCESS_CODE).message(SUCCESS_MESSAGE).build();
    }

    public static R ok(Object data){
        return R.builder().code(SUCCESS_CODE).message(SUCCESS_MESSAGE).data(data).build();
    }

    public static R fail(){
        return R.builder().code(ERROR_CODE).message(ERROR_MESSAGE).build();
    }

    public static R fail(Object data){
        return R.builder().code(ERROR_CODE).message(ERROR_MESSAGE).data(data).build();
    }


}
